﻿using System;

namespace SmartMathLibrary.Storage
{
    /// <summary>
    /// Supports all methods to implement a basic storage for point.
    /// </summary>
    public interface IAbstractPointStorage
    {
        /// <summary>
        /// Gets the enumerator of the storage. This will be used to realize a for each loop.
        /// </summary>
        /// <returns>The current enumerator of the object.</returns>
        System.Collections.Generic.IEnumerator<StoragePoint> GetEnumerator();

        /// <summary>
        /// Ascertained the largest x value of the storage.
        /// </summary>
        /// <value>The largest x value of the storage.</value>
        double MaxX { get; }

        /// <summary>
        /// Ascertained the largest x value of the storage.
        /// </summary>
        /// <value>The smallest x value of the storage.</value>
        double MinX { get; }

        /// <summary>
        /// This method is a high performance search method, which selects a specified position range
        /// defined by the smallest and largest x value. If the specified values are not available in the 
        /// storage, it will automatically search an approximate value.
        /// </summary>
        /// <param name="minX">The smallest x value for the selection.</param>
        /// <param name="maxX">The largest x value for the selection.</param>
        /// <returns>The indices of the nearest minimum and maximum x values in the current storage.</returns>
        StorageSelectionResult SelectPositionData(double minX, double maxX);

        /// <summary>
        /// This method is a high performance search method, which selects a specified position range
        /// defined by the smallest and largest x value. If the specified values are not available in the 
        /// storage, it will automatically search an approximate value.
        /// </summary>
        /// <param name="definition">The definition of the position range to select.</param>
        /// <returns>The indices of the nearest minimum and maximum x values in the current storage in form of a 
        /// <see cref="StorageSelectionDefinition"/>.</returns>
        StorageSelectionResult SelectPositionData(StorageSelectionDefinition definition);

        /// <summary>
        /// Gets the size of the storage.
        /// </summary>
        /// <value>The size of the storage.</value>
        int StorageSize { get; }

        /// <summary>
        /// Gets the <see cref="SmartMathLibrary.Storage.StoragePoint"/> at the specified index.
        /// </summary>
        /// <value>The specified index.</value>
        StoragePoint this[int index] { get; }
    }
}